package com.youxue.teachin.set.child.xuekexueduan.binder;

import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.library.xtype.DefaultNuwaItemBinder;
import com.youxue.teachin.R;
import com.youxue.teachin.set.child.xuekexueduan.vo.ItemVO;

/**
 * 在此写用途
 *
 * @author: zhiwei
 * @date: 2017-10-07 16:57
 * @version: 9.1.0
 */
public class ItemBinder extends DefaultNuwaItemBinder<ItemVO> {
    private View mRootView;
    private ImageView mIcon;
    private TextView mName;
    ItemVO mItemVO;
    @Override
    public View onCreateView(View convertView, ViewGroup parent, LayoutInflater inflater) {
        View view = inflater.inflate(R.layout.set_xuekexuduan_item_layout, parent, false);
        initView(view);
        return view;
    }

    @Override
    public void onBindView(int positionOfFeeds, View convertView, ViewGroup parent, ItemVO vo) {
        mItemVO = vo;
        if (vo.mIconRes != 0) {
            mIcon.setImageResource(vo.mIconRes);
        }
        mName.setText(vo.name);
        mRootView.setTag(vo);
    }

    private void initView(View rootView) {
        mRootView = rootView;
        mIcon = (ImageView)rootView.findViewById(R.id.icon);
        mName = (TextView)rootView.findViewById(R.id.name);
    }

    @Override
    public void setOnClickListener(OnClickListener listener) {
        super.setOnClickListener(listener);
        mRootView.setOnClickListener(listener);
    }

}
